<?php

/**
 * Represents an entry in a thread
 * 
 * @author Marcel Linnenfelser
 */
class BoardEntry
{

    var $data;
    var $depth;
    var $children;
    var $template;

    function BoardEntry($data, & $template)
    {
        $this->data = $data;
        $this->template = & $template;
    }

    function setDepth($depth)
    {
        $this->depth = $depth;
    }

    function add(& $child)
    {
        if (is_array($child))
        {
            $this->children = & $child;
            for ($i = 0; $i < count($this->children);$i++)
            {
                $this->children[$i]->setDepth($this->depth + 1);
            }
        }
        else
        {
            $this->children[] = & $child;
            $child->setDepth($this->depth + 1);
        }
    }

    function paint($mode)
    {
        $html = $this->template->paint($this->data, $this->depth, $mode);
        for ($i = 0; $i < count($this->children); $i++)
        {
            $html .= $this->children[$i]->paint($mode);
        }
        return $html;
    }

    function getID()
    {
        return $this->data["id"];
    }

}

?>